<template>
<div class='header-container'>
  <div class="header-wrap">
    <div class="header">
      <!-- logo -->
      <div class="logo-wrap">
        <a href="/">
          <img class="logo" src="@/assets/images/logo.png" alt="">
        </a>
        <!-- 字 -->
        <div class="header-text">CyberOS</div>
      </div>
      <!-- 按钮部分 -->
      <div class="tools-wrap">
        <div class="tools">
          <el-button round @click="onAbout">{{$t('home.about')}}</el-button>
          <el-button round @click="onDos">{{$t('home.dos')}}</el-button>
          <el-button round @click="onDownload">{{$t('home.download')}}</el-button>
          <el-button round @click="onGithub">Github</el-button>
          <el-button round @click="onChangeLang">{{language}}</el-button>
        </div>
      </div>
    </div>
  </div>
</div>
</template>

<script>

export default {
  name: 'HomeHeader',
  components: {},
  props: {},
  data () {
    return {
      language: 'English'
    }
  },
  computed: {},
  watch: {},
  methods: {
    onGithub () {
      window.location.href = 'https://github.com/cyberos'
    },
    onDownload () {
      window.location.href = 'https://dir.omame.tech/cyberos-iso/CyberOS-latest-x86_64.iso'
      this.$router.push('/download')
      if (this.$i18n.locale === 'zh-CN') {
        this.$message({
          message: '感谢你的下载',
          type: 'success'
        })
      } else {
        this.$message({
          message: 'Thank you for downloading',
          type: 'success'
        })
      }
    },
    onDos () {
      if (this.$i18n.locale === 'zh-CN') {
        this.$message({
          message: '不好意思哦，暂时还没有做这个功能',
          type: 'warning'
        })
      } else {
        this.$message({
          message: 'Sorry, I haven\'t done this function yet',
          type: 'warning'
        })
      }
    },
    onChangeLang () {
      if (this.language === 'English') {
        this.language = '中文'
        this.$i18n.locale = 'en-US'
      } else {
        this.language = 'English'
        this.$i18n.locale = 'zh-CN'
      }
      console.log(this.$i18n.locale)
    },
    onAbout () {
      this.$router.push('/about')
    }
  },
  created () {},
  mounted () {}
}
</script>
<style lang="less" scoped>
.header-container {
  height: 100px;
  .header-wrap {
    background-color: #fff;
    .header {
      display: flex;
      justify-content: space-between;
      height: 66px;
      margin: 20px 50px;
      .logo-wrap {
        display: flex;
        align-items: center;
        margin-right: 30px;
        .logo {
          width: 50px;
          height: 50px;
        }
      }
      .header-text {
        text-align: center;
        font-size: 50px;
        margin-left: 30px;
      }
      .tools-wrap {
        display: flex;
        align-items: center;
      }
    }
  }
}
</style>
